package com.xc.utils;

import java.util.Random;

/**
 *
 * @author xiongcan
 * @version 1.0
 * @date 2018/4/13 下午6:36
 */
public class KeyUtils {


    //  生成唯一的主键 格式：时间+ 6位随机数 5个0
    public static String getUniqueKey(){
        Random random = new Random();
        Integer number = random.nextInt(900) + 100;

        return System.currentTimeMillis() + String.valueOf(number);
    }

    //  得到代理推广code
    public static String getAgentUniqueKey(){
        Random random = new Random();
        Integer number = random.nextInt(900000) + 100000;
        return PropertiesUtil.getProperty("agent.key.prefix") + String.valueOf(number);
    }

    //  得到五位随机数
    public static String getFiveUnique(){
        Random random = new Random();
        Integer number = random.nextInt(90000) + 10000;
        return String.valueOf(number);
    }



    //  得到充值订单号
    public static String getRechargeOrderSn(){
        return "C"+KeyUtils.getUniqueKey();
    }

    //  得到提现订单号
    public static String getWithdrawOrderSn(){
        return "W"+KeyUtils.getUniqueKey();
    }




    public static void main(String[] args) {
        String s1 = "A4058C23D071BF034EDA3E1181BC1EE8";
        String s2 = "A4058C23D071BF034EDA3E1181BC1EE8";

        System.out.println(s1.equals(s2));


        System.out.println(KeyUtils.getUniqueKey());
        System.out.println(KeyUtils.getAgentUniqueKey());
        System.out.println(KeyUtils.getFiveUnique());

    }


}
